﻿namespace EyeOpen.SecurityService.Wcf
{
    using System;
    using System.Collections.Generic;

    public partial class SecurityService : ISecurityServiceWcf
    {
        private const string HardCodedUser = "user1";
        
        private const string HardCodedAdminUser = "admin1";

        ////The password hash for the clear password "password"
        private const string PasswordHashConst = "X03MO1qnZdYdgyfeuILPmQ==";

        public bool IsValidUser(string username, string passwordHash)
        {
            if (username.Equals(HardCodedUser, StringComparison.InvariantCultureIgnoreCase))
            {
                if (passwordHash == PasswordHashConst)
                {
                    return true;
                }
            }    
            else if (username.Equals(HardCodedAdminUser, StringComparison.InvariantCultureIgnoreCase))
            {
                if (passwordHash == PasswordHashConst)
                {
                    return true;
                }
            }

            return false;
        }

        public string[] GetRoleForUser(string username)
        {
            if (username.StartsWith("admin", StringComparison.InvariantCultureIgnoreCase))
            {
                return new string[] { "Admins" };
            }
            else
            {
                return new string[] { };
            }
        }
    }
}
